USE [NANS21V]
GO

/****** オブジェクト: SqlProcedure [dbo].[KonseiRekidaiDetails] スクリプト日付: 2014/05/16 14:49:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KonseiRekidaiDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[KonseiRekidaiDetails]
GO

CREATE PROCEDURE [dbo].[KonseiRekidaiDetails]
	@TAIKAINO int,
	@REKIDAINO int
AS
		SELECT 
		A.ID, 
		B.SYUMOKUMEI,
		B.KIROKUKUBUN, 
		dbo.Kiroku(A.KIROKU,B.SYUMOKUKUBUN,B.KIROKUKUBUN,A.SOKUTEI) AS KIROKU,
		A.SOKUTEI 
	FROM 
		TBL_REKIDAI_KONSEI AS A 
	LEFT JOIN 
		TBL_SYUMOKU_MASTER AS B 
	ON 
		A.SYUMOKUNO = B.SYUMOKUNO 
	WHERE 
		(A.TAIKAINO = @TAIKAINO) 
		AND (A.REKIDAINO = @REKIDAINO) 
	ORDER BY 
		A.ID